//计算 8 + 88 + 888 + ... 直到第 12 项的总和
public class SumOfEights {
	public static void main(String[] args) {
		int levels = 12; // 12级
		long sum = 0;    // 用于存储总和，使用long防止溢出
		long current = 0; // 用于存储当前项

		System.out.println("计算8 + 88 + 888 + ... + 12级的总和：");

		for (int i = 1; i <= levels; i++) {
			// 计算当前项：前一项 * 10 + 8
			current = current * 10 + 8;
			sum += current;

			// 打印每一项，最后一项不打印加号
			System.out.print(current);
			if (i < levels) {
				System.out.print(" + ");
			}
		}

		System.out.println(" = " + sum);
	}
}